<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:t="http://tms" xml:lang="en" lang="en">

<ui:composition template="../securedTemplate.xhtml">
    <ui:define name="childMetadata">
        <f:event type="preRenderView" listener="#{profileViewBean.cleanUp}"/>
    </ui:define>
    <ui:define name="title">#{localizer.localized('PROFILE_SETTINGS')}</ui:define>

    <ui:define name="body">
        <ui:decorate template="../navigationTabs.xhtml">
            <ui:param name="currentTab" value="profile"/>

            <table style="font-size:smaller;color:black;width:400px;">
                <tr>
                    <td align="left" valign="top">
                        <table width="100%">
                            <tr>
                                <td align="left">
                                    #{localizer.localized('COMMON_SETTINGS')}
                                </td>
                                <td align="right">
                                    <h:graphicImage name="images/tools.png" style="padding-top:5px;"/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <div class="panelFrame">
                                        <f:ajax event="keypress" listener="#{profileViewBean.onContentUpdate}" immediate="true" render="profileBtnPanel" onerror="ajaxErrorsHandler">
                                            <input type="hidden" name="local" value="true"/>
                                            <table>
                                                <tr>
                                                    <td class="labelsColumn">
                                                        #{localizer.localized('WORK_DAY')} <b>*</b>:
                                                    </td>
                                                    <td>
                                                        <h:inputText value="#{profileViewBean.profile.workDayLength}" size="5" maxlength="5" required="true"
                                                                     converter="totalTime" style="width:35px;"
                                                                     requiredMessage="#{localizer.localized('WORK_DAY')}#{localizer.localized('REQUIRED')}" onkeypress="return filterInput(event);"/>
                                                        #{localizer.localized('TIME_FORMAT')}
                                                    </td>
                                                </tr>
                                            </table>
                                        </f:ajax>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <table width="100%">
                            <tr>
                                <td align="left">
                                    <f:ajax event="change" listener="#{profileViewBean.onContentUpdate}" render="mailSettingsPanel profileBtnPanel" onerror="ajaxErrorsHandler">
                                        <h:selectBooleanCheckbox value="#{profileViewBean.profile.mailActive}"/>
                                        <input type="hidden" name="local" value="true"/>
                                    </f:ajax>
                                    #{localizer.localized('NOTIFY_BY_EMAIL')}
                                </td>
                                <td align="right">
                                    <h:graphicImage name="images/email-icon.gif" style="padding-top:10px;"/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <h:panelGroup id="mailSettingsPanel" layout="block">
                                        <h:panelGroup layout="block" rendered="#{profileViewBean.profile.mailActive}" styleClass="panelFrame">
                                            <f:ajax event="keypress" listener="#{profileViewBean.onContentUpdate}" immediate="true" render="profileBtnPanel" onerror="ajaxErrorsHandler">
                                                <input type="hidden" name="local" value="true"/>
                                                <table>
                                                    <tr>
                                                        <td class="labelsColumn">
                                                            #{localizer.localized('EMAIL')} <b>*</b>:
                                                        </td>
                                                        <td>
                                                            <h:inputText value="#{profileViewBean.profile.mailAddress}" size="30" maxlength="255" required="#{profileViewBean.profile.mailActive}"
                                                                         requiredMessage="#{localizer.localized('EMAIL')}#{localizer.localized('REQUIRED')}"
                                                                         validatorMessage="#{localizer.localized('EMAIL_INVALID')}" onkeypress="return filterInput(event);">
                                                                <f:validateRegex pattern="(\w+|(\w+-\w+))@(\w+|(\w+-\w+))\.\w{1,3}"/>
                                                            </h:inputText>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="labelsColumn">
                                                            #{localizer.localized('MAIL_SUBJECT')} <b>*</b>:
                                                        </td>
                                                        <td>
                                                            <h:inputText value="#{profileViewBean.profile.mailSubject}" size="30" maxlength="255" required="#{profileViewBean.profile.mailActive}"
                                                                         requiredMessage="#{localizer.localized('MAIL_SUBJECT')}#{localizer.localized('REQUIRED')}" onkeypress="return filterInput(event);"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="labelsColumn">
                                                            #{localizer.localized('MAIL_MESSAGE')} <b>*</b>:
                                                        </td>
                                                        <td>
                                                            <h:inputTextarea value="#{profileViewBean.profile.mailMessage}" rows="3" cols="27" required="#{profileViewBean.profile.mailActive}" style="font-family:fantasy;font-size:larger;"
                                                                         requiredMessage="#{localizer.localized('MAIL_MESSAGE')}#{localizer.localized('REQUIRED')}" onkeypress="return filterInput(event);"/>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </f:ajax>
                                        </h:panelGroup>
                                    </h:panelGroup>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <table width="100%">
                            <tr>
                                <td align="left">
                                    <f:ajax event="change" listener="#{profileViewBean.onContentUpdate}" render="autostopPanel profileBtnPanel" onerror="ajaxErrorsHandler">
                                        <h:selectBooleanCheckbox value="#{profileViewBean.profile.autostop}"/>
                                        <input type="hidden" name="local" value="true"/>
                                    </f:ajax>
                                    #{localizer.localized('AUTOSTOP')}
                                </td>
                                <td align="right">
                                    <h:graphicImage name="images/clock.gif" style="padding-top:10px;"/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <h:panelGroup id="autostopPanel" layout="block">
                                        <h:panelGroup layout="block" rendered="#{profileViewBean.profile.autostop}" styleClass="panelFrame">
                                            <f:ajax event="keypress" listener="#{profileViewBean.onContentUpdate}" immediate="true" render="profileBtnPanel" onerror="ajaxErrorsHandler">
                                                <input type="hidden" name="local" value="true"/>
                                                <table>
                                                    <tr>
                                                        <td class="labelsColumn">
                                                            #{localizer.localized('AUTOSTOP_IN')} <b>*</b>:
                                                        </td>
                                                        <td>
                                                            <h:inputText value="#{profileViewBean.profile.autostopTime}" size="5" maxlength="5" required="#{profileViewBean.profile.autostop}"
                                                                         converter="totalTime" style="width:35px;" title="#{localizer.localized('AUTOSTOP_INFO')}"
                                                                         requiredMessage="#{localizer.localized('AUTOSTOP_IN')}#{localizer.localized('REQUIRED')}" onkeypress="return filterInput(event);"/>
                                                            #{localizer.localized('TIME_FORMAT')}
                                                        </td>
                                                    </tr>
                                                </table>
                                            </f:ajax>
                                        </h:panelGroup>
                                    </h:panelGroup>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <table width="100%">
                            <tr>
                                <td align="left">
                                    <f:ajax event="change" listener="#{profileViewBean.onContentUpdate}" render="jabberPanel profileBtnPanel" onerror="ajaxErrorsHandler">
                                        <h:selectBooleanCheckbox value="#{profileViewBean.profile.jabberActive}"/>
                                        <input type="hidden" name="local" value="true"/>
                                    </f:ajax>
                                    #{localizer.localized('JABBER_INTEGRATION')}
                                </td>
                                <td align="right">
                                    <h:graphicImage name="images/jabber.png" style="padding-top:10px;"/>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <h:panelGroup id="jabberPanel" layout="block">
                                        <h:panelGroup layout="block" rendered="#{profileViewBean.profile.jabberActive}" styleClass="panelFrame">
                                            <table>
                                                <tr>
                                                    <td class="labelsColumn">
                                                        #{localizer.localized('JABBER_LOGIN')} <b>*</b>:
                                                    </td>
                                                    <td>
                                                        <f:ajax event="keypress" listener="#{profileViewBean.onContentUpdate}" immediate="true" render="profileBtnPanel" onerror="ajaxErrorsHandler">
                                                            <h:inputText value="#{profileViewBean.profile.jabberId}" size="30" maxlength="50" required="#{profileViewBean.profile.jabberActive}"
                                                                         requiredMessage="#{localizer.localized('JABBER_LOGIN')}#{localizer.localized('REQUIRED')}"
                                                                         validatorMessage="#{localizer.localized('JABBER_LOGIN_INVALID')}" onkeypress="return filterInput(event);">
                                                                <f:validateRegex pattern="(\w+|(\w+-\w+))@(\w+|(\w+-\w+))\.\w{1,3}"/>
                                                            </h:inputText>
                                                            <input type="hidden" name="local" value="true"/>
                                                        </f:ajax>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="labelsColumn">
                                                        #{localizer.localized('STOP_WHEN_STATUS')} <b>*</b>:
                                                    </td>
                                                    <td>
                                                        <f:ajax listener="#{profileViewBean.onContentUpdate}" render="profileBtnPanel" onerror="ajaxErrorsHandler">
                                                            <h:selectOneMenu value="#{profileViewBean.profile.jabberPauseStatus}" required="#{profileViewBean.profile.jabberActive}"
                                                                             requiredMessage="#{localizer.localized('STOP_WHEN_STATUS')}#{localizer.localized('REQUIRED')}">
                                                                <f:selectItem itemLabel="" itemValue=""/>
                                                                <c:forEach var="status" items="#{profileViewBean.jabberUserStatuses}">
                                                                    <f:selectItem itemLabel="#{localizer.localized(status)}" itemValue="#{status}"/>
                                                                </c:forEach>
                                                            </h:selectOneMenu>
                                                            <input type="hidden" name="local" value="true"/>
                                                        </f:ajax>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="labelsColumn">
                                                        <f:ajax event="change" listener="#{profileViewBean.onContentUpdate}" render="jabberPanel profileBtnPanel" onerror="ajaxErrorsHandler">
                                                            <h:selectBooleanCheckbox value="#{profileViewBean.profile.jabberNotify}"/>
                                                            <input type="hidden" name="local" value="true"/>
                                                        </f:ajax>
                                                    </td>
                                                    <td>
                                                        <b>*</b> #{localizer.localized('NOTIFY_ABOUT_DAY_END')}
                                                    </td>
                                                </tr>
                                                <h:panelGroup rendered="#{profileViewBean.profile.jabberNotify}">
                                                    <tr>
                                                        <td class="labelsColumn">
                                                            #{localizer.localized('MESSAGE')} <b>*</b>:
                                                        </td>
                                                        <td>
                                                            <f:ajax event="keypress" listener="#{profileViewBean.onContentUpdate}" immediate="true" render="profileBtnPanel" onerror="ajaxErrorsHandler">
                                                                <h:inputTextarea value="#{profileViewBean.profile.jabberNotifyMessage}" rows="3" cols="27" required="#{profileViewBean.profile.jabberNotify}" style="font-family:fantasy;font-size:larger;"
                                                                             requiredMessage="#{localizer.localized('MESSAGE')}#{localizer.localized('REQUIRED')}" onkeypress="return filterInput(event);"/>
                                                            </f:ajax>
                                                        </td>
                                                    </tr>
                                                </h:panelGroup>
                                            </table>
                                        </h:panelGroup>
                                    </h:panelGroup>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td valign="top" align="center">
                        <h:panelGroup id="profileBtnPanel" layout="block" styleClass="buttonwrapper" style="padding-top:30px;">
                            <div class="#{profileViewBean.contentUpdated ? '' : ', veil'}"></div>
                            <table>
                                <tr>
                                    <td>
                                        <h:commandLink action="#{profileViewBean.updateProfile}" styleClass="ovalbutton">
                                            <span>#{localizer.localized('SAVE')}</span>
                                        </h:commandLink>
                                        <h:commandLink action="#{profileViewBean.cancel}" styleClass="ovalbutton" immediate="true">
                                            <span>#{localizer.localized('CANCEL')}</span>
                                        </h:commandLink>                                        
                                    </td>
                               </tr>
                            </table>
                        </h:panelGroup>
                    </td>
                </tr>
            </table>
            <script type="text/javascript">
                function filterInput(event) {
                    var code = event.which;
                    if (code &#38;&#38;
                        code != 37 &#38;&#38;
                        code != 38 &#38;&#38;
                        code != 39 &#38;&#38;
                        code != 40) {
                        return true;
                    } else {
                        return false;
                    }
                }
            </script>
        </ui:decorate>
    </ui:define>
</ui:composition>

</html>